-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style(rich-text-editor): adjust style, fit Highlight, Default, Disabled #357
Conversation
const file = event.target.files[0]; | ||
if (!file.type.match("image.*")) { | ||
alert("请选择图片文件!"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Caesar-ch 代码格式不对,缩进应该是两个空格,并且没有末尾分号
bold加粗 | ||
<button @click="state.editor.chain().focus().toggleBold().run()" | ||
:class="{ 'is-active': state.editor?.isActive('bold') }"> | ||
<svg t="1690608596338" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Caesar-ch svg图片应该使用单独的xxx.svg
图片保存,而不是直接放到模板里,确保代码的可维护性
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那是在pc.vue所在目录里新建个assets文件夹里面存下载的svg图片吗
@@ -131,50 +373,139 @@ export default defineComponent({ | |||
// props: [...props, 'type', 'text', 'size', 'icon', 'resetTime', 'nativeType', 'loading', 'disabled', 'plain', 'autofocus', 'round', 'circle', 'tabindex'], | |||
components: { EditorContent }, | |||
setup(props, context) { | |||
return setup({ props, context, renderless, api, extendOptions: { useEditor, Collaboration, StarterKit, Y, WebrtcProvider, Table, TableCell, TableHeader, TableRow, Color, TextStyle, Image } }) | |||
return setup({ props, context, renderless, api, extendOptions: { useEditor, Collaboration, StarterKit, Y, WebrtcProvider, Table, TableCell, TableHeader, TableRow, Color, TextStyle, Image, Highlight, Link, Underline, Subscript, Superscript } }) | |||
} | |||
}) | |||
</script> | |||
|
|||
<style lang="less"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
样式请加上 scoped,避免样式污染
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Caesar-ch 样式文件需要单独存放在 packages/theme 子包中,不要直接放到模板里,另外样式需要有两个文件index.less
/vars.less
,index.less 中使用 vars.less 中的CSS Var主题变量
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
编辑器最好装一个eslint插件,自动安装eslint规则格式化代码
if (url) { | ||
editor.chain().focus().setImage({ src: url }).run() | ||
} | ||
const editor = useEditor({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一块的配置看能不能单独抽离出去,让用户可以自定义
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块的抽离的话我想着是往后面,那版专门抽离配置,所以目前没考虑
} | ||
const setLink = () => { | ||
const previousUrl = editor.value.getAttributes('link').href | ||
const url = window.prompt('URL', previousUrl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果url存在,不需要做操作吗?
alert("请选择图片文件!"); | ||
return; | ||
} | ||
var reader = new FileReader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要用var, 没改变的变量统一用const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
const handleChange = (event) => { | ||
const file = event.target.files[0]; | ||
if (!file.type.match("image.*")) { | ||
alert("请选择图片文件!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也不要用alert,可以引用组件库提示组件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
* feat(rich-text-editor): add new component rich-text-editor (#346) * feat(rich-text-editor): add new components rich-text-editor --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * style(rich-text-editor): adjust style, fit Highlight, Default, Disabled (#357) * style(rich-text-editor): adjust style, fit Highlight, Default, Disabled * fix(rich-text-editor): Space format changed from four to two * fix(rich-text-editor): add svg file and support high light and disabled and default --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * feat(rich-text-editor): add text alignment, task list, table interaction (#372) * feat(rich-text-editor): add text alignment, task list, table interaction --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> --------- Co-authored-by: Caesar-ch <74941512+Caesar-ch@users.noreply.github.com> Co-authored-by: 常浩-BJS21325 <changhao01@youdao>
* feat(rich-text-editor): add new component rich-text-editor (#346) * feat(rich-text-editor): add new components rich-text-editor --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * style(rich-text-editor): adjust style, fit Highlight, Default, Disabled (#357) * style(rich-text-editor): adjust style, fit Highlight, Default, Disabled * fix(rich-text-editor): Space format changed from four to two * fix(rich-text-editor): add svg file and support high light and disabled and default --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * feat(rich-text-editor): add text alignment, task list, table interaction (#372) * feat(rich-text-editor): add text alignment, task list, table interaction --------- Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * perf(rich-text-editor): split pure function from vue.ts to index.ts (#395) Co-authored-by: 常浩-BJS21325 <changhao01@youdao> * fix(rich-text-editor): fix conflict --------- Co-authored-by: Caesar-ch <74941512+Caesar-ch@users.noreply.github.com> Co-authored-by: 常浩-BJS21325 <changhao01@youdao>
PR
PR Checklist
加入svg图形,增加默认选中,高亮,禁用状态样式
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Add svg icon, support highlighting , default, disabled style
Does this PR introduce a breaking change?
Other information